<?php

namespace App\View\Component;

use Hyperf\ViewEngine\Component\Component;
use function Hyperf\ViewEngine\view;


/**
 * ^2_3^ Alert自定义组件
 * 
 * 错误提示：Fatal error: Declaration of App\View\Component\Alert::render() must be compatible with Hyperf\ViewEngine\Component\Component::render(): mixed in /data/project/project-php-hyperf3.1.19-skeleton/source/app/View/Component/Alert.php on line 26
 * 解决方法：定义方法返回类型“mixed”
 */
class Alert extends Component
{
    // 公共属性都将自动传递给组件视图
    public $type;
    public $message;

    public function __construct($type, $message)
    {
        $this->type = $type;
        $this->message = $message;
    }
    
    /**
     * 组件渲染
     * @description: 自定义渲染组件，需要指定方法返回值"mixed"
     * @return {*}
     */    
    public function render(): mixed
    {
        return view('components.alert');
    }
}
